package com.demo.service.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author cjy
 * @since 2024-10-29
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class DbLockDto implements Serializable {

    private final static long EXPIRED_MILLS = 5 * 60 * 1000;

    private Integer id;

    private String key;

    private Date createTime;

    public boolean isExpired() {
        return (System.currentTimeMillis() - this.getCreateTime().getTime() < EXPIRED_MILLS);
    }

}
